#include "stdafx.h"

void GRect::update_brush()
{
	if (brush)
	{
		delete brush;
	}

	brush = new Gdiplus::SolidBrush(color);
}

GRect::GRect(int width, int height, int left, int top) :Rectangle(width, height)
{
	this->left = left;
	this->top = top;

	update_brush();
}

GRect::~GRect()
{
	delete brush;
}

void GRect::draw(Gdiplus::Graphics & graphics)
{
	graphics.FillRectangle(brush, left, top, get_x(), get_y());
}

void GRect::set_color(Gdiplus::Color color)
{
	this->color = color;

	update_brush();
}